package com.ctgu.蓝桥杯真题.B组2016;

import java.io.*;
import java.util.HashMap;

/**
 * @author: Backdiy
 * @data: 2021/4/14 17:08
 * @desc:
 */
public class H四平方和 {
    public static void main(String[] args) throws IOException {
        long n = IO.nextLong();
        solve1(n);
        solve2(n);
        IO.out.flush();
    }
//利用HashMap保存值，然后查询
    static void solve2(long n) {
        HashMap<Long, Long> integers = new HashMap<>();
        long x = n / 2;
        long y = n / 4;
        for (long a = 0; a * a <= x; a++) {
            for (long b = a; a * a + b * b <= n; b++) {
                long z = a * a + b * b;
                if (!integers.containsKey(z)) {
                    integers.put(z, a);
                }
            }
        }
        for (int c = 0; c * c <= y; c++) {
            for (int d = c; c * c + d * d <= x; d++) {
                long z = c * c + d * d;
                long m = n - z;
                if (integers.containsKey(m)) {
                    long a = integers.get(m);
                    long b = (long) Math.sqrt(m - a * a);
                    IO.out.println("" + c + " " + d + " " + a + " " + b);
                    return;
                }
            }
        }
    }
//优化遍历
    static void solve1(long n) {
        for (long a = 0; a <= n; a++) {
            for (long b = a; a * a + b * b <= n; b++) {
                for (long c = 0; a * a + b * b + c * c <= n; c++) {
                    long d = n - a * a - b * b - c * c;
                    long m = (long) Math.sqrt(d);
                    if (m * m == d) {
                        IO.out.println("" + a + " " + b + " " + c + " " + m);
                        return;
                    }
                }
            }
        }
    }

    static class IO {
        static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        static BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        static public int nextInt() throws IOException {
            in.nextToken();
            return (int) in.nval;
        }

        static public double nextDouble() throws IOException {
            in.nextToken();
            return in.nval;
        }

        static public String readLine() throws IOException {
            return read.readLine();
        }

        static public String nextLine() throws IOException {
            in.nextToken();
            return in.sval;
        }

        public static long nextLong() throws IOException {
            in.nextToken();
            return (long) in.nval;
        }
    }
}
